Skip to content

ast,checker: add type checking for param of fn passed as generic arg#26257

Merged
spytheman merged 10 commits intovlang:masterfrom
dy-tea:type-check
Feb 4, 2026
Merged

ast,checker: add type checking for param of fn passed as generic arg#26257
spytheman merged 10 commits intovlang:masterfrom
dy-tea:type-check

Conversation

@dy-tea
Copy link
Member

@dy-tea dy-tea commented Jan 3, 2026

Fixes #26195.

@dy-tea
Copy link
Member Author

dy-tea commented Jan 3, 2026

Adventofcode has a cgen issue, will look into it.

@dy-tea dy-tea marked this pull request as draft January 4, 2026 00:02
@spytheman
Copy link
Member

This PR managed to find implicit type conversion bugs in stats.v , which is a very good sign.
Thank you @dy-tea .

@spytheman
Copy link
Member

the vlib/v/slow_tests/inout/publish_shared_object_method_call.vv failure can be worked around with:

 fn (shared eb EventBus[T]) publish(event_type EventType, data T) {
        lock eb {
                for _, subscriber in eb.subscribers[event_type] {
-                       subscriber(data)
+                       subscriber[T](data)
                }
        }
 }

but imho should not have to, the type should have been inferred

@dy-tea
Copy link
Member Author

dy-tea commented Jan 6, 2026

Good that it is finding issues. Been kind of going in circles fixing a test and a different one breaks for a while :/

@dy-tea
Copy link
Member Author

dy-tea commented Jan 8, 2026

Just rebased to master for now.

@dy-tea
Copy link
Member Author

dy-tea commented Jan 8, 2026

I believe this is also a type promotion bug:

 FAIL  [1096/2677] C:  1448.9 ms, R:     0.000 ms vlib/v/tests/comptime/comptime_infix_assign_test.v
>> compilation failed:
vlib/v/tests/comptime/comptime_infix_assign_test.v:20:21: error: cannot use `int` as `u64` in argument 1 to `u64_to_hex`
   18 |             else { return '' }
   19 |         }
   20 |         return u64_to_hex(item, len)
      |                           ~~~~
   21 |     } $else $if T is $array {
   22 |         mut hex := ''

@dy-tea
Copy link
Member Author

dy-tea commented Feb 3, 2026

Aaaaah going in circles.

@dy-tea dy-tea marked this pull request as ready for review February 3, 2026 17:54
@dy-tea
Copy link
Member Author

dy-tea commented Feb 3, 2026

Looks like it's working now.

@dy-tea dy-tea requested a review from spytheman February 3, 2026 18:05
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.
Thank you @dy-tea for persevering 🙇🏻 .

@spytheman spytheman merged commit 844c332 into vlang:master Feb 4, 2026
90 checks passed
@dy-tea dy-tea deleted the type-check branch February 4, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

checker: missing type checking when generic fn is passed to generic struct fn

2 participants